openerp.portal_channel = function(instance) {
    var QWeb = instance.web.qweb,
        _t = instance.web._t;

    instance.web.portal_channel = instance.web.portal_channel || {};

    instance.web.views.add('tree_channel', 'instance.web.portal_channel.IssueListView');
    instance.web.portal_channel.IssueListView = instance.web.ListView.extend({
        init: function() {
            var self = this;
            this._super.apply(this, arguments);
            this.on('list_view_loaded', this, function() {
                if(self.__parentedParent.$el.find('.oe_channel_product_card_active').length == 0){
                     var button = $("<button type='button' class='oe_button oe_channel_product_card_active'>批量激活</button>")
                         .click(this.proxy('channel_product_card_active_action'));
                     self.__parentedParent.$el.find('.oe_list_buttons').append(button);
                }
            });
        },
        channel_product_card_active_action: function () {
            var self = this;
            var action_manager = new instance.web.ActionManager(self);

            return action_manager.do_action('portal_channel.channel_product_card_active_action', {
                        on_close: function () {
                            self.do_search(self.last_domain, self.last_context, self.last_group_by);
                        }
            });

        },

        //重载列表数据
        do_search: function(domain, context, group_by) {
            var self = this;
            this.last_domain = domain;
            this.last_context = context;
            this.last_group_by = group_by;
            this.old_search = _.bind(this._super, this);
            return self.old_search(new instance.web.CompoundDomain(self.last_domain), self.last_context, self.last_group_by);
        },
    });
}
